package lib

import (
	"database/sql"
	"log"
)

type Processer struct {
	CenterID          int64          `db:"msgCenterID"`
	QueueID           int64          `db:"queueID"`
	CallUrl           string         `db:"callUrl"`
	CallRequestTypeID int8           `db:"callRequestTypeID"`
	Askb2cflag        int8           `db:"askb2cflag"`
	OtherCenterUrl    sql.NullString `db:"otherCenterUrl"`
	OtherCenterQueue  sql.NullString `db:"otherCenterQueue"`
	ToOtherCenter     int8           `db:"toOtherCenter"`
}

func FetchOneProcesser(queueID int64) *Processer {
	row := Dbconn.SelectOne("select msgCenterID,queueID,callUrl,callRequestTypeID,askb2cflag,otherCenterUrl,otherCenterQueue,toOtherCenter from msgProcessor WHERE validFlag=1 AND deletedFlag=0 AND queueID=?", queueID)
	p := new(Processer)
	e := row.Scan(&p.CenterID, &p.QueueID, &p.CallUrl, &p.CallRequestTypeID, &p.Askb2cflag, &p.OtherCenterUrl, &p.OtherCenterQueue, &p.ToOtherCenter)
	if e != nil {
		log.Fatal(e)
	}
	return p
}
